<?php include "../../inc/classes.inc" ?>
<?php include "../../inc/constants.inc" ?>
<?php session_start(); ?>
<?php
    if ( isset($_GET['player_list_id']) == false || isset($_SESSION['user']) == false ) {
		redirect("/tornooien/zt-php/view_players_list.php");
    }

    $playerListId = $_GET['player_list_id'];
    $user = $_SESSION['user'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Tornooien</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../assets/css/default.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../../assets/js/ajax.js" />
</script>
</head>

<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" class="default">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="7">
                        <img src="../../assets/images/spacer.gif" height="1" width="7" ALT="">
                    </td>
                    <td width="150" align="left"><img src="../../assets/images/headerbar_kerst.gif" alt="" ></td>

                </tr>
                <tr>
                    <td colspan="2" height="12"><img src="../../assets/images/spacer.gif" alt="" height="12" width="1"></td>
                </tr>
            </table>
        </td>
        <td align="right" valign="top">
		<br/>
        <a href="../../logout.php?redirect=/tornooien/zt-php/view_players_list.php"><img src="../../assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
		<br>&nbsp;<br>
		<span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>
<?php
	$action = null;
    if ( isset($_GET['action']) == true ) $action = $_GET['action'];

    mysql_connect(DB_SERVER, DB_USER, DB_PWD);
    mysql_select_db(DB_CATALOG);

    $query = "select u.user_id, u.club_id from zt_player_list pl join user u on u.user_id = pl.user_id where pl.player_list_id = ".$playerListId;
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $userId = $row['user_id'];
    $clubId = $row['club_id'];

    if ( isset($_SESSION["players"]) && $action != 'reset' ) {
        $playersListEdit = $_SESSION["players"];
        //echo "player 0 ploegnr : ".$playersListEdit[0]->team_name;
        if ( isset($_GET['row']) == true ) {
            $row = $_GET['row'];
            if ($action == 'remove') {
                array_deleteobj($playersListEdit, $row - 1);
            } else if ($action == 'up') {
                array_switchobj($playersListEdit, $row - 2, $row - 1);
            } else if ($action == 'down') {
                array_switchobj($playersListEdit, $row - 1, $row);
            }
            $_SESSION["players"] = $playersListEdit;
        }

    } else {
        $result = mysql_query("select zp.index_nr, p.club, p.matricule, p.nom_prenom, p.sexe, p.date_naiss,
            p.elo_calcul, p.part_calcu, t.team_nr from zt_player_list pl join zt_player zp on zp.player_list_id = pl.player_list_id
            left outer join playernew p on zp.player_key = p.matricule left outer join zt_team t on t.team_id = zp.team_id
            where pl.player_list_id = ".$playerListId." order by zp.index_nr");
        if (mysql_num_rows($result) >= 1) {
            $index = 0;
            $playersListEdit = array();
            while ($row = mysql_fetch_assoc($result)) {
                if (!isset($playerId) || $playerId != $row['matricule']) {
                    $playerId = $row['matricule'];
                    $player = new Player;
                    $player->player_id = $row['matricule'];
                    $player->club_id = $row['club'];
                    $player->player_key = $row['matricule'];
                    $player->player_name = $row['nom_prenom'];
                    $player->gender = $row['sexe'];
                    $player->dob = $row['date_naiss'];
                    $player->elo = $row['elo_calcul'];
                    $player->game_count = $row['part_calcu'];
                    $player->team_name = $row['team_nr'];
                    $player->index_nr = $row['index_nr'];
                    $playersListEdit[$index++] = $player;
                }
            }
            $_SESSION["players"] = $playersListEdit;
        }
    }

    $result = mysql_query("SELECT clubname from club where club_id = ".$user->club_id);
    $row = mysql_fetch_assoc($result);
    $clubname = $row['clubname'];
    mysql_free_result($result);
?>
</td>
		<td>&nbsp;</td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
    <tr>
        <td align="left">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td rowspan="2" width="7"><img src="../../assets/images/spacer.gif" alt="" height="1" width="7"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
					<td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/newsbox.php" target="_top"><span class="tabName">Nieuwsbox</span></a></td>
					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
					<td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_FFFFFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="activeSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/tornooien/tornooien.html" target="_top"><span class="tabName">Tornooien</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_FFFFFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/bestuur/bestuur.php" target="_top"><span class="tabName">Bestuur</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/advalvas/index.html" target="_top"><span class="tabName">Ad Valvas</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="http://www.frbe-kbsb.be/EloHist/FRBE_Fiche.php" target="_blank"><span class="tabName">ELO</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/clubs/clubs.php" target="_top"><span class="tabName">Clubs</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/jeugd/index.html" target="_top"><span class="tabName">Jeugd</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/links/index.php" target="_top"><span class="tabName">Links</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>
				</tr>
				<tr>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="activeSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="activeSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td width="100%" bgcolor="#FFFFFF" colspan="13"><img border="0" width="30" src="../../assets/images/FFFFFF.gif" height="12" alt=""></td>
	</tr>
</table>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">
	<tr>
		<td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#666666">
			<table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">
				<tr><td>&nbsp;</td></tr>
			</table>
		</td>
		<td id="header" valign="top" width="100%">
			<table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#666666" width="40%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#666666" align="right" valign="top">&nbsp;
                          <span class="headerSmall">Huidige versie PLAYER.DBF: <?=CURRENT_PLAYER_DBF?>
                        <?php
                        if (isset($user) && $user->club_id == 100) {
                        ?>
                        <br/>
                        <a class="headerSmall" href="import_player.php">laad andere versie</a>
                        <?php
                        }
                        ?>
                        </span>
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.php"); ?> 
                </tr>
				<tr><td colspan="2" nowrap bgcolor="#BCDD10" height="4"><img src="../../assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>
				<tr>
					<td>&nbsp;</td>
					<td valign="top">
						<table align="left" cellspacing="10" width="100%">
							<tr>
								<td>
                  <?php
                  	if (isset($user)) {
                  ?>
                  <span class="blackHeaderLarge"><?=CURRENT_ZT_TOURNAMENT?> - Invoer spelerslijst <?=$clubname?></span>
									<br>&nbsp;<br>
                  <a href="view_players_list.php"><img src="../../assets/images/24x24/shadow/document.gif" border="0" alt="Ga naar overzicht spelerslijsten"/></a>
                  &nbsp;&nbsp;
                  <a href="edit_player_list.php?player_list_id=<?=$playerListId?>&action=reset"><img src="../../assets/images/24x24/shadow/recycle.gif" border="0" alt="Reset spelerslijst"/></a>
                  &nbsp;&nbsp;
                  <a href="validate_player_list.php?player_list_id=<?=$playerListId?>"><img src="../../assets/images/24x24/shadow/document_check.gif" border="0" alt="Valideer spelerslijst"/></a>
                  <span class="hidden" id="noKeyFound">Stamnummer niet gevonden.</span>
                  <span class="hidden" id="noValidTeam">Ploegnummertoewijzing is niet geldig voor deze speler.</span>
                  <span class="hidden" id="playerNameIsFixed">Naam van speler mag niet gewijzigd worden.</span>
                  <span class="hidden" id="playerNameStoreError">Naam van speler kon niet gevalideerd worden.</span>
                  <span class="hidden" id="playerEloIsInvalid">ELO-waarde is geen geldig getal.</span>
                  <span class="hidden" id="playerEloIsFixed">ELO voor bestaande speler kan niet gewijzigd worden.</span>
                  <span class="hidden" id="playerClubIsInvalid">Clubnummer ongeldig of onbestaand.</span>
                  <span class="hidden" id="playerClubIsFixed">Clubnummer van bestaande speler mag niet gewijzigd worden.</span>
                  <br>&nbsp;<br>
                  <table width="70%" border="0" cellpadding="0" cellspacing="0" id="test">
                    <tr>
											<td width="5%"><strong>Volgnr</strong></td>
											<td width="10%" align="center"><strong>Stamnr</strong>&nbsp;&nbsp;</td>
											<td width="5%" align="center"><strong>Ploegnr</strong></td>
											<td width="60%"><strong>Naam</strong></td>
											<td width="10%" align="center"><strong>ELO</strong></td>
											<td width="10%" align="center"><strong>Kring</strong></td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
										</tr>
										<form id="playerListForm" action="validate_player_list.php" method="POST">
                    <?php
                        if (count($playersListEdit) == 0) {
                        	$indexNr = 0;
                    ?>
                            <tr>
                               <td align="center"><strong><?=$indexNr + 1?></strong></td>
                               <td class="clsTableInputForm" align="center"><input size="10"  name="playerKey_<?=$indexNr + 1?>" class="clsInputForm" onblur="getPlayer(this.value,<?=$indexNr + 1?>,'', '', '')"></td>
                               <td class="clsTableInputForm" align="center"><input size="10"  name="teamName_<?=$indexNr + 1?>" class="clsInputForm" value="&nbsp;" onblur="storePlayerTeam(this.value,'',<?=$clubId?>,<?=$indexNr + 1?>,'')"/></td>
                               <td class="clsTableInputForm"><input size="45" style="text-align:left" name="playerName_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerName(this.value,<?=$indexNr + 1?>,'')"/></td>
                               <td class="clsTableInputForm" align="center"><input size="10"  name="playerElo_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerElo(this.value,<?=$indexNr + 1?>,'')"/></td>
                               <td class="clsTableInputForm" align="center"><input size="10"  name="playerClub_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerClub(this.value,<?=$indexNr + 1?>,'')"/></td>
                               <td class="clsTableInputForm">&nbsp;</td>
                               <td class="clsTableInputForm">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/delete2.gif"></a></td>
                               <td class="clsTableInputForm">&nbsp;</td>
                               <td class="clsTableInputForm">&nbsp;</td>
                               <td class="clsTableInputForm">&nbsp;&nbsp;<a href="insert_player_list.php?row=<?=$indexNr + 2?>&action=add"><img border="0" src="../../assets/images/16x16/shadow/add2.gif"></a></td>
                           </tr>
                    <?php
                        }

                        $row = null;
    					if ( isset($_GET['row']) == true ) $row = $_GET['row'];

                        while ($player = current($playersListEdit)) {
                           $indexNr = key($playersListEdit);
                           if ($row == $indexNr + 1) { // row equals the current player
                               if ($action == 'insert') {
                                   $emptyPlayer = New Player;
                                   $emptyPlayer->playerKey = null;
                                   $emptyPlayer->name = null;
                                   $emptyPlayer->elo = null;
                      ?>
                                   <tr>
                                       <td align="center"><strong><?=$indexNr + 1?></strong></td>
                                       <td class="clsTableInputForm" align="center"><input size="10" name="playerKey_<?=$indexNr + 1?>" class="clsInputForm" onblur="getPlayer(this.value,<?=$indexNr + 1?>,'', '', '')"></td>
                                       <td class="clsTableInputForm" align="center"><input size="10" name="teamName_<?=$indexNr + 1?>" class="clsInputForm" onblur="storePlayerTeam(this.value,'',<?=$clubId?>,<?=$indexNr + 1?>,'')"/></td>
                                       <td><span class="hidden" id="playerName_<?=$indexNr + 1?>" name="playerName_<?=$indexNr + 1?>"></span></td>
                                       <td align="center"><span class="hidden" id="playerElo_<?=$indexNr + 1?>" name="playerElo_<?=$indexNr + 1?>"></span></td>
                                       <td align="center"><span class="hidden" id="playerClub_<?=$indexNr + 1?>" name="playerClub_<?=$indexNr + 1?>"></span></td>
                                       <td>&nbsp;</td>
                                       <td>&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/arrow_right_blue.gif" alt="verwijder"></a></td>
                                       <td>&nbsp;</td>
                                       <td>&nbsp;</td>
                                       <td>&nbsp;</td>
                                    </tr>
                      <?php
                                    // since the inserted value is an object we have to treat it differently,
                                    array_insertobj($playersListEdit, $indexNr, $emptyPlayer);
                                    $_SESSION["players"] = $playersListEdit;
                                    // the function went to the beginning of the array when done, so go to the correct current
                                    // position
                                    for ($i = 0; $i < $row; $i++) {
                                      next($playersListEdit);
                                    }
                                }
                            }

                            if ( empty($player->player_key) ) {
                              	
                            	// TODO new players show in red
                            	
                            	$result = mysql_query("select p.player_id, p.club, p.matricule, p.nom_prenom, p.sexe, p.date_naiss, p.elo_calcul, p.part_calcu,
                                t.team_nr from zt_player_list pl join zt_player zp on zp.player_list_id = pl.player_list_id
                                join playernew p on zp.player_key = p.matricule left outer join zt_team t on t.team_id = zp.team_id
                                where pl.player_list_id = ".$playerListId." and zp.index_nr = ".$player->index_nr." order by zp.index_nr");
                            	
                            	if ( mysql_errno() == 0 ) {
                            		$row = mysql_fetch_assoc($result);
	                              	$player->player_id = $row['matricule'];
	                              	$player->player_key = $row['matricule'];
	                              	$player->club_id = $row['club'];
	                              	$player->player_name = $row['nom_prenom'];
	                              	$player->elo = $row['elo_calcul'];
                            	}
                          ?>
                              <tr>
                                <td style="background-color:#DD0000;color:#FFFFCC" align="center"><strong><?=key($playersListEdit) + 1?></strong></td>
                                <td class="clsTableInputForm" align="center"><input size="10" name="playerKey_<?=key($playersListEdit) + 1?>" class="clsInputForm" value="<?=$player->player_key?>" onblur="getPlayer(this.value,<?=$indexNr + 1?>,'', '', '')"></td>
                                <td class="clsTableInputForm" align="center"><input size="10" name="teamName_<?=key($playersListEdit) + 1?>" class="clsInputForm" value="<?=$player->team_name?>" onblur="storePlayerTeam(this.value,'',<?=$clubId?>,<?=$indexNr + 1?>,'')" /></td>
                                <td><span class="default" id="playerName_<?=key($playersListEdit) + 1?>" name="playerName_<?=key($playersListEdit) + 1?>">&nbsp;&nbsp;<?=$player->player_name?></span></td>
                                <td align="center"><span class="default" id="playerElo_<?=key($playersListEdit) + 1?>" name="playerElo_<?=key($playersListEdit) + 1?>">&nbsp;&nbsp;<?=$player->elo?></span></td>
                                <td align="center"><span class="default" id="playerClub_<?=key($playersListEdit) + 1?>" name="playerClub_<?=key($playersListEdit) + 1?>">&nbsp;&nbsp;<?=$player->club_id?></span></td>
                                <td align="center">&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=insert"><img border="0" src="../../assets/images/16x16/shadow/arrow_left_green.gif" alt="voeg in"></a></td>
                                <td align="center">&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/delete2.gif" alt="verwijder"></a></td>
                          <?php
							} else {
                          ?>
                              <tr>
                                <td align="center"><strong><?=key($playersListEdit) + 1?></strong></td>
                                <td class="clsTableInputForm" align="center"><input size="10" name="playerKey_<?=key($playersListEdit) + 1?>" class="clsInputForm" value="<?=$player->player_key?>"></td>
                                <td class="clsTableInputForm" align="center"><input size="10" name="teamName_<?=key($playersListEdit) + 1?>" class="clsInputForm" value="<?=$player->team_name?>" onblur="storePlayerTeam(this.value,'',<?=$clubId?>,<?=$indexNr + 1?>,'')" /></td>
                                <td><span class="default" id="playerName_<?=key($playersListEdit) + 1?>" name="playerName_<?=key($playersListEdit) + 1?>">&nbsp;&nbsp;<?=$player->player_name?></span></td>
                                <td><span class="default" id="playerElo_<?=key($playersListEdit) + 1?>" name="playerElo_<?=key($playersListEdit) + 1?>">&nbsp;&nbsp;<?=$player->elo?></span></td>
                                <td><span class="default" id="playerClub_<?=key($playersListEdit) + 1?>" name="playerClub_<?=key($playersListEdit) + 1?>">&nbsp;&nbsp;<?=$player->club_id?></span></td>
                                <td align="center">&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=insert"><img border="0" src="../../assets/images/16x16/shadow/arrow_left_green.gif" alt="voeg in"></a></td>
                                <td align="center">&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/delete2.gif" alt="verwijder"></a></td>
                          <?php
                            }

                            if($indexNr != 0) { // first row
                        ?>
                            <td align="center">&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=up"><img border="0" src="../../assets/images/16x16/shadow/arrow_up_green.gif" alt="duw naar boven"></a></td>
                        <?php
                          	} else {
                        ?>
                              <td>&nbsp;</td>
                        <?php
                              }
                          	if($indexNr + 1 != count($playersListEdit)) { // row is not last row
                        ?>
                            <td align="center">&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=down"><img border="0" src="../../assets/images/16x16/shadow/arrow_down_blue.gif" alt="duw naar onder"></a></td>
                        <?php
                          	} else {
                        ?>
                              <td>&nbsp;</td>
                        <?php
                              }
                          	if($indexNr + 1 == count($playersListEdit) && $action != 'add') { // row is last row
                        ?>
                            <td>&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 2?>&action=add"><img border="0" src="../../assets/images/16x16/shadow/add2.gif" alt="voeg toe"></a></td>
                        <?php
                          	}
                        ?>
                        </tr>
                        <?php
                      			if ($action == 'add' && $indexNr + 1 == count($playersListEdit) && $row == $indexNr + 2) {
                              $emptyPlayer = New Player;
                              $emptyPlayer->playerKey = null;
                              $emptyPlayer->name = null;
                              $emptyPlayer->elo = null;
                        ?>
                              <tr>
                                  <td align="center"><strong><?=$indexNr + 2?></strong></td>
                                  <td class="clsTableInputForm" align="center"><input size="10"  name="playerKey_<?=$indexNr + 2?>" class="clsInputForm" onblur="getPlayer(this.value,<?=$indexNr + 2?>,'', '', '')"></td>
                                  <td class="clsTableInputForm" align="center"><input size="10"  name="teamName_<?=$indexNr + 2?>" class="clsInputForm" value="&nbsp;" onblur="storePlayerTeam(this.value,'',<?=$clubId?>,<?=$indexNr + 2?>,'')"/></td>
                                  <td><span class="default" id="playerName_<?=$indexNr + 2?>" name="playerName_<?=$indexNr + 2?>"></span></td>
                                  <td align="center"><span class="default" id="playerElo_<?=$indexNr + 2?>" name="playerElo_<?=$indexNr + 2?>"></span></td>
                                  <td align="center"><span class="default" id="playerClub_<?=$indexNr + 2?>" name="playerClub_<?=$indexNr + 2?>"></span></td>
                                  <td>&nbsp;</td>
                                  <td>&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 2?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/arrow_right_blue.gif" alt="verwijder"></a></td>
                                  <td>&nbsp;</td>
                                  <td>&nbsp;</td>
                                  <td>&nbsp;&nbsp;<a href="edit_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 3?>&action=add"><img border="0" src="../../assets/images/16x16/shadow/add2.gif"></a></td>
                              </tr>
                           <?php
                            	array_addobj($playersListEdit, $emptyPlayer);
                            	$_SESSION["players"] = $playersListEdit;
                                prev($playersListEdit);
                            }

                            next($playersListEdit);
                    		}

										?>
										<tr>
											<td colspan="11">&nbsp;</td>
										</tr>
										</form>
									</table>
                                    <?php
                                        } else {
                                    ?>
                                    <span class="blackHeaderLarge"><?=CURRENT_ZT_TOURNAMENT?> - Invoer spelerslijst</span>
									<br>&nbsp;<br>
									<strong>U moet ingelogd zijn om een spelerslijst te kunnen invoeren.</strong>
                                    <?php
                                        }
									?>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
			</table>
		</td>
	</tr>
</table>

<?php include("footer.php") ?>
